﻿(function () {
    "use strict";

    var demoApp = angular.module('demoApp', []);

    demoApp.factory("someDataService", function () {

        var mockDatas = [];
        var init = function () {
            mockDatas = [
            {
                Id: 0,
                Videos: ["视频1", "视频2", "视频3", "视频4", "视频5"]
            },
            {
                Id: 1,
                Videos: ["视频6", "视频7", "视频8", "视频9"]
            }];

            return mockDatas;
        };

        var getSomeData = function (id, page) {
            console.log("invoke service with : (" + id + "," + page + ")");
            init();
            return mockDatas[id].Videos.slice(0, page);
        };

        return {
            init: init,
            get: getSomeData
        };
    });

    demoApp.controller('repeatsController', ['$scope', 'someDataService', function ($scope, someDataService) {
        
        //初始化VO
        $scope.array = someDataService.init();

        //按钮单机的事件
        $scope.getSomeData = function (id, page) {
            $scope.array[id].Videos = someDataService.get(id, page);
        };

    }]);

}());